package com.线程和进程;

public class MyRunnableDemo {
    public static void main(String[] args) {
        //创建MyRunnable类的对象
        MyRunnable my = new MyRunnable();

        //创建Thread类的对象，把MyRunnable对象作为构造方法的参数

        /*Thread(Runnable target) 分配一个新的 Thread对象*/
//        Thread t1 = new Thread(my);
//        Thread t2 = new Thread(my);

        /*Thread(Runnable target, String name) 分配一个新的 Thread对象。*/
        Thread t1 = new Thread(my, "高铁");
        Thread t2 = new Thread(my, "飞机");

        //启动线程
        t1.start();
        t2.start();
    }
}
